import { Button } from "antd"
import styles from './index.less'
import { useModel } from "@umijs/max"
type Props = {
    children?: any;
    text?: string;
    buttonStyle?: any;
  };
export default ({
    children,
    text='登录 | 注册',
    buttonStyle= {},
}:Props) =>{
    const {setShowLogin,userInfo} = useModel('global');
    return <>
    {
        !!userInfo?.id ?
         <>{children}</>:
         <>
            <Button style={buttonStyle} className={styles.btn} onClick={(e)=>{
                e.stopPropagation()
                setShowLogin(true)
            }}>
                <span>{text}</span>
            </Button> 
         </>
         
    }
    </>
}